package com.chuangyi.forme.login.service.impl;

import java.sql.SQLException;

import com.chuangyi.forme.common.sys.User;
import com.chuangyi.forme.login.dao.UserLoginDao;
import com.chuangyi.forme.login.service.UserLoginService;

public class UserLoginServiceImpl implements UserLoginService {
	private UserLoginDao userLoginDao;
	
	public UserLoginDao getUserLoginDao() {
		return userLoginDao;
	}

	public void setUserLoginDao(UserLoginDao userLoginDao) {
		this.userLoginDao = userLoginDao;
	}

	public boolean userLogin(User user) throws SQLException {
		boolean success = false;
		success = this.userLoginDao.checkUserByName(user.getUsername());
		if(success){
			String password = this.userLoginDao.getPasswordByName(user.getUsername());
			if(user.getPassword().equals(password)){
				success = true;
			}else{
				success = false;
			}
		}
		return success;
	}
	public boolean ogin(User user) throws SQLException {
		boolean success = false;
		success = this.userLoginDao.checkUserByName(user.getUsername());
		if(success){
			String password = this.userLoginDao.getPasswordByName(user.getUsername());
			if(user.getPassword().equals(password)){
				success = true;
			}else{
				success = false;
			}
		}
		return success;
	}

}
